package com.example.demo1014;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

public class MyAidlService extends Service {

    private static final String TAG = "MyAidlService";

    private IMyAidlInterface.Stub binder = new IMyAidlInterface.Stub() {

        @Override
        public void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, double aDouble, String aString) throws RemoteException {

        }

        @Override
        public void myMethod(int value) throws RemoteException {

            int val = value;
            Log.d(TAG, "myMethod: value --> " + val);
        }

        @Override
        public String getString() throws RemoteException {
            return "Hello from AIDL!";
        }
    };

    public MyAidlService() {

        Log.d(TAG, "MyAidlService(): ");
    }

    @Override
    public void onCreate() {

        super.onCreate();
        Log.d(TAG, "MyAidlService() onCreate : ");
    }

    @Override
    public IBinder onBind(Intent intent) {

        return binder;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.d(TAG, "MyAidlService() onDestroy : ");
    }
}